package com.cainiao.mapper;

import com.cainiao.pojo.Student;
import com.cainiao.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {

    List<Student> findStudent(StudentQueryParam studentQueryParam);

    void delete(List<Long> ids);

    @Insert("insert into student(name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id,create_time,update_time)values " +
            "(#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})" )
    void add(Student student);

    @Select("select * from student where id=#{id}")
    Student findById(Integer id);

    void update(Student student);

    @Update("update student set violation_score=violation_score+#{score},violation_count=violation_count+1 where id=#{id}")
    void updateViolation(Integer id, Integer score);

    @Select("select count(*) from student where clazz_id=#{id}")
    Integer countByClazzId(Integer id);

    @MapKey("name")
    List<Map> studentDegreeData();
    

    @MapKey("name")
    List<Map> studentCountData();
}
